package com.scalar.chiptrack.adaptor.ikanos.stats;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Date;

import com.scalar.ScalarException;
import com.scalar.chiptrack.adaptor.AdaptorConstants;
import com.scalar.chiptrack.adaptor.AdaptorUtils;
import com.scalar.chiptrack.adaptor.AssemblyLot;
import com.scalar.chiptrack.adaptor.InventoryLot;
import com.scalar.chiptrack.adaptor.ShippedLot;
import com.scalar.chiptrack.adaptor.TestLot;
import com.scalar.chiptrack.adaptor.FabSortLot;
import com.scalar.chiptrack.adaptor.utils.ParserResult;
import com.scalar.chiptrack.adaptor.utils.Parser;
import com.scalar.chiptrack.adaptor.utils.ParserFactory;
import com.scalar.chiptrack.adaptor.utils.CSVParserImpl;
import com.scalar.chiptrack.adaptor.dao.AdaptorDAO;
import com.scalar.chiptrack.adaptor.dao.AdaptorRunInfo;
import com.scalar.chiptrack.adaptor.dao.AssemblyAdaptorDAO;
import com.scalar.chiptrack.adaptor.dao.InventoryLotDAO;
import com.scalar.chiptrack.adaptor.dao.ShippedLotDAO;
import com.scalar.chiptrack.adaptor.dao.TestAdaptorDAO;
import com.scalar.chiptrack.adaptor.dao.FabSortAdaptorDAO;
import com.scalar.chiptrack.jobs.JobHandler;
import com.scalar.chiptrack.utils.Logger;
import com.scalar.chiptrack.utils.StringUtils;
/**
 * User: ChandraSekhar
 * Date: Jul 22, 2008
 * Time: 4:46:41 PM
 */
public class STATSDataParser extends JobHandler implements AdaptorConstants
{
    private HashMap<String, FabSortLot> m_sortDataMap       = new HashMap<String, FabSortLot>();
    private HashMap<String, InventoryLot> m_dieBankDataMap	= new HashMap<String, InventoryLot>();
    private HashMap<String, AssemblyLot> m_assyDataMap      = new HashMap<String, AssemblyLot>();
    private HashMap<String, TestLot> m_ftDataMap            = new HashMap<String, TestLot>();
    private HashMap<String, InventoryLot> m_preTestDataMap  = new HashMap<String, InventoryLot>();
    private HashMap<String, InventoryLot> m_eolDataMap      = new HashMap<String, InventoryLot>();
	private HashMap<String, InventoryLot> m_scsfgDataMap    = new HashMap<String, InventoryLot>();
	private HashMap<String, InventoryLot> m_sckfgDataMap    = new HashMap<String, InventoryLot>();
	private HashMap<String, InventoryLot> m_scmfgDataMap    = new HashMap<String, InventoryLot>();
	private HashMap<String, ShippedLot> m_assyShipDataMap   = new HashMap<String, ShippedLot>();
	private HashMap<String, ShippedLot> m_ftShipDataMap     = new HashMap<String, ShippedLot>();
	private HashMap<String, AssemblyLot> m_assyYieldMap     = new HashMap<String, AssemblyLot>();

    private Logger m_parserLogger   = null;
    private String m_dataOutputDir  = null;

    public STATSDataParser() throws ScalarException
    {
        try
        {
            m_dataOutputDir = AdaptorUtils.getDataOutputDir(VENDOR_NAME_SCS, WIP_TYPE_ASSEMBLY);
            AdaptorUtils.makeAllAdaptorDirs( m_dataOutputDir );
            m_parserLogger = AdaptorUtils.getDataParserLogger( m_dataOutputDir,VENDOR_NAME_SCS );
            AssemblyAdaptorDAO.setLogger( m_parserLogger );
            TestAdaptorDAO.setLogger( m_parserLogger );
            InventoryLotDAO.setLogger(m_parserLogger);
            ShippedLotDAO.setLogger( m_parserLogger );
            FabSortAdaptorDAO.setLogger( m_parserLogger );
            AdaptorUtils.setLogger( m_parserLogger );
        }
        catch (ScalarException se)
        {
            log("ERROR!! ERROR!! ERROR!! Exception while loading STATS WIP output directory details from database, Exception: " + se);
            throw se;
        }
    }
    /**
     *
     * @param args
     * @throws Exception
     */
    public static void main( String args[] ) throws Exception
    {
        try
        {
            new STATSDataParser().execute();
        }
        catch (Exception e)
        {
            throw e;
        }
    }
    /**
     *
     * @throws Exception
     */
    public void execute() throws Exception
    {
        AdaptorUtils.printHeader( "STATS ", CONSTANT_PARSER);

        File doneDestDir = new File(  m_dataOutputDir + "/done" );

        File sourceDataoutDir = new File( m_dataOutputDir );

        File[] fileList = sourceDataoutDir.listFiles();
        if ( ( fileList == null ) || ( fileList.length <= 3 ) )
        {
            log( "No file found in directory: " + sourceDataoutDir );
            throw new ScalarException( "\n+-----------No file found in directory " + sourceDataoutDir );
        }

        ArrayList<File> successFileList = new ArrayList<File>();

        boolean success = false;

        for ( int i = 0; i < fileList.length; i++ )
        {
            if ( fileList[i].isDirectory() == true )
            {
                continue;
            }

            try
            {
                // Step 1
                // Parse Files to get Object List
                if ( fileList[i].getName() != null && fileList[i].getName().trim().startsWith( STATSAdaptor.FILE_NAME_WIP_INVENTORY ) )
                {
                    // To parse the the STATS_WIP_STATUS sheet in to table
                    //ArrayList<STATSWipStatus> wipInventoryList = parseTurnKeyWipReport( fileList[i].getAbsolutePath() );
                    parseAllWipReport( fileList[i].getAbsolutePath() );

                    /*if ( wipInventoryList != null && wipInventoryList.size() > 0 )
                    {
                        //to get the STATS Wip Details details
                        getAllWipInventoryDetails( wipInventoryList );
                    }*/

                    successFileList.add( fileList[i] );
                }
                if ( fileList[i].getName() != null && fileList[i].getName().trim().startsWith( STATSAdaptor.FILE_NAME_DROP_SHIP ) )
                {
                    // To parse the the STATS DROP SHIP Inventory sheet
                    ArrayList<STATSWipStatus> dropShipList = parseDropShipmentReport( fileList[i].getAbsolutePath() );

                    if ( dropShipList != null && dropShipList.size() > 0 )
                    {
                        //to get the STATS Drop Ship Details details
                        getAllDropShippingDetails( dropShipList );
                    }

                    successFileList.add( fileList[i] );
                }
                if ( fileList[i].getName() != null && fileList[i].getName().trim().startsWith( STATSAdaptor.FILE_NAME_SCS_TRANSACTION) )
                {
                    // To parse the the STATS TransAction Report
                    ArrayList<STATSWipStatus> transActionList = parseSCSTransactionReport( fileList[i].getAbsolutePath() );

                    if ( transActionList != null && transActionList.size() > 0 )
                    {
                        //to get the STATS TransAction Report details
                        getAllTransactionDetails( transActionList );

                    }

                    successFileList.add( fileList[i] );
                }
                 if ( fileList[i].getName() != null && fileList[i].getName().trim().startsWith( STATSAdaptor.FILE_NAME_TRANSACTION) )
                {
                    // To parse the the STATS(SCK,SCC,SCM) TransAction Report
                    parseTransactionReport( fileList[i].getAbsolutePath() );

                    successFileList.add( fileList[i] );
                }
                success = true;
            }
            catch ( Exception e )
            {
                success = false;
                log( "Exception while parsing and storing file: " + fileList[i].getAbsolutePath() + "\nException: " + e );
                e.printStackTrace();
                throw e;
            }
        }
        /*Updating the Wafer Store Lot Information*/
        /*try
        {
            // Save Wafer Store Information
            if (m_waferStoreDataMap.isEmpty() == false)
            {
                log(" Updating Wafer Store Lot Information");
                InventoryLotDAO.saveInventoryLot(null, m_waferStoreDataMap.values().iterator(), LOCATION_TYPE_WAFER_STORE, VENDOR_NAME_SCS);
            }
            else
            {
                InventoryLotDAO.closeInventoryLot(null, LOCATION_TYPE_WAFER_STORE, VENDOR_NAME_SCS);
            }
            success = true;
            m_waferStoreDataMap.clear();
            m_waferStoreDataMap = null;
        }
        catch (ScalarException se)
        {
            success = false;
            se.printStackTrace();
            log("ERROR!! ERROR!! ERROR!! Could not update Wafer Store Lot information into database: " + se);
            throw se;
        }*/

        //to saving sort Lot Info
        try
        {
            // Save Sort Information
            if ( m_sortDataMap.isEmpty() == false )
            {
                log( " Updating Sort Lot Information" );
                FabSortAdaptorDAO.saveSortLot( null, m_sortDataMap.values().iterator(), WIP_TYPE_SORT, null );
            }
            else
            {
                FabSortAdaptorDAO.closeSortLot( null, WIP_TYPE_SORT, null );
            }
            success = true;
            m_sortDataMap.clear();
            m_sortDataMap = null;
        }
        catch (ScalarException se)
        {
            success = false;
            se.printStackTrace();
            log( "ERROR!! ERROR!! ERROR!! Could not update Sort Lot information into database: " + se );
            throw se;
        }

        /*Updating the Die Bank Lot Information*/
        try
        {
            // Save Die Bank Information
            if (m_dieBankDataMap.isEmpty() == false)
            {
                log(" Updating Die Bank Lot Information");
                InventoryLotDAO.saveInventoryLot(null, m_dieBankDataMap.values().iterator(), LOCATION_TYPE_DIE_BANK, null);
            }
            else
            {
                InventoryLotDAO.closeInventoryLot(null, LOCATION_TYPE_DIE_BANK, null/* All the four vendors*/);
            }
            success = true;
            m_dieBankDataMap.clear();
            m_dieBankDataMap = null;
        }
        catch (ScalarException se)
        {
            success = false;
            se.printStackTrace();
            log("ERROR!! ERROR!! ERROR!! Could not update Die Bank Lot information into database: " + se);
            throw se;
        }

        /*Assembly Lot Saving*/
        try
        {
            // Save Assembly Information
            if ( m_assyDataMap.isEmpty() == false )
            {
                log( " Updating Assembly Lot Information" );
                AssemblyAdaptorDAO.saveAssemblyLot( null, m_assyDataMap.values().iterator(), WIP_TYPE_ASSEMBLY, null );
            }
            else
            {
                AssemblyAdaptorDAO.closeAssemblyLot( null, WIP_TYPE_ASSEMBLY, null);
            }
            success = true;
            m_assyDataMap.clear();
            m_assyDataMap = null;

        }
        catch (ScalarException se)
        {
            success = false;
            se.printStackTrace();
            log( "ERROR!! ERROR!! ERROR!! Could not update SCS/SCK Assembly Lot information into database: " + se );
            throw se;
        }

        try
        {
            // Save Assembly Ship Information
            if ( m_assyShipDataMap.isEmpty() == false )
            {
                log( " Updating Assembly Shiping Lot Information" );
                ShippedLotDAO.saveShippedLot( null, m_assyShipDataMap.values().iterator() );
            }
            success = true;
            m_assyShipDataMap.clear();
            m_assyShipDataMap = null;
        }
        catch (ScalarException se)
        {
            success = false;
            se.printStackTrace();
            log( "ERROR!! ERROR!! ERROR!! Could not update Assembly Shipping Lot information into database: " + se );
            throw se;
        }
        try
       {
           if ( !m_assyYieldMap.isEmpty() )
           {
               log(" Saving the assembly In transaction report information");

               AssemblyAdaptorDAO.saveAssemblyTransactionInQty( null, m_assyYieldMap.values().iterator() );
           }
       }
       catch (Exception e)
       {
           success = false;
            e.printStackTrace();
            log( "ERROR!! ERROR!! ERROR!! Could not update Assembly Yield Lot information into database: " + e );
            throw e;
       }
        // to save the Class Stroe lot tables
       try
       {
           if ( m_preTestDataMap.isEmpty() == false )
           {
               log(" Updating Class Stroe Lot Information");
               InventoryLotDAO.saveInventoryLot( null, m_preTestDataMap.values().iterator(), LOCATION_TYPE_PRE_TEST, null );
               success = true;
           }
           else
           {
               InventoryLotDAO.closeInventoryLot(null, LOCATION_TYPE_PRE_TEST, null  );
           }
      }
      catch (ScalarException se)
      {
          success = false;
          se.printStackTrace();
          log("ERROR!! ERROR!! ERROR!! Could not update Class Stroe Lot information into database: " + se);
          throw se;
      }
        // Saving the Test Lot Information
        try
        {
            // Save Final Test Information
            if ( m_ftDataMap.isEmpty() == false )
            {
                log( " Updating Test Lot Information" );
                TestAdaptorDAO.saveTestLot( null, m_ftDataMap.values().iterator(), LOCATION_TYPE_FT, null );
            }
            else
            {
                TestAdaptorDAO.closeTestLot( null, LOCATION_TYPE_FT, null );
            }

            success = true;
            m_ftDataMap.clear();
            m_ftDataMap = null;
        }
        catch (ScalarException se)
        {
            success = false;
            se.printStackTrace();
            log( "ERROR!! ERROR!! ERROR!! Could not update Test Lot information into database: " + se );
            throw se;
        }

        try
        {
            // Save FT Ship Information
            if ( m_ftShipDataMap.isEmpty() == false )
            {
                log( " Updating FT Shiping Lot Information" );
                ShippedLotDAO.saveShippedLot( null, m_ftShipDataMap.values().iterator() );
            }
            success = true;
            m_ftShipDataMap.clear();
            m_ftShipDataMap = null;
        }
        catch (ScalarException se)
        {
            success = false;
            se.printStackTrace();
            log( "ERROR!! ERROR!! ERROR!! Could not update FT Shipping Lot information into database: " + se );
            throw se;
        }

        try
        {
           if ( m_eolDataMap.isEmpty() == false )
           {
               log(" Updating EOL Class Stroe Lot Information");
               InventoryLotDAO.saveInventoryLot( null, m_eolDataMap.values().iterator(), LOCATION_TYPE_EOL, null );
               success = true;
           }
           else
           {
               InventoryLotDAO.closeInventoryLot(null, LOCATION_TYPE_EOL, null  );
           }
        }
        catch (ScalarException se)
        {
          success = false;
          se.printStackTrace();
          log("ERROR!! ERROR!! ERROR!! Could not update EOL Class Stroe Lot information into database: " + se);
          throw se;
       }

	   // to save the FG lot tables
       try
       {   //FG Only for SCS Vendor
           if ( m_scsfgDataMap.isEmpty() == false )
           {
               log(" Updating Finshed Goods Lot Information");
               InventoryLotDAO.saveInventoryLot(null, m_scsfgDataMap.values().iterator(), LOCATION_TYPE_FG, VENDOR_NAME_SCS );
               success = true;
           }
           else
           {
               InventoryLotDAO.closeInventoryLot(null, LOCATION_TYPE_FG, VENDOR_NAME_SCS  );
           }
           if ( m_sckfgDataMap.isEmpty() == false )
           {
               log(" Updating Finshed Goods Lot Information");
               InventoryLotDAO.saveInventoryLot(null, m_sckfgDataMap.values().iterator(), LOCATION_TYPE_FG, VENDOR_NAME_SCK );
               success = true;
           }
           else
           {
               InventoryLotDAO.closeInventoryLot(null, LOCATION_TYPE_FG, VENDOR_NAME_SCK  );
           }
           if ( m_scmfgDataMap.isEmpty() == false )
           {
               log(" Updating Finshed Goods Lot Information");
               InventoryLotDAO.saveInventoryLot(null, m_scmfgDataMap.values().iterator(), LOCATION_TYPE_FG, VENDOR_NAME_SCM );
               success = true;
           }
           else
           {
               InventoryLotDAO.closeInventoryLot(null, LOCATION_TYPE_FG, VENDOR_NAME_SCM  );
           }
       }
       catch (ScalarException se)
       {
          success = false;
          se.printStackTrace();
          log("ERROR!! ERROR!! ERROR!! Could not update Finshed Goods Lot information into database: " + se);
          throw se;
       }

       // To Close the Drop Out Lots
       AdaptorDAO.closeDropOutLots(VENDOR_NAME_SCS);
       AdaptorDAO.closeDropOutLots(VENDOR_NAME_SCK);
       AdaptorDAO.closeDropOutLots(VENDOR_NAME_SCC);
       AdaptorDAO.closeDropOutLots(VENDOR_NAME_SCM);

      // TO SEND THE NEW LOTS, NEW TRANSIT LOTS, NO PO LOTS, DISCREPANCY LOTS NOTIFICATIONS TO THE USER
      AdaptorDAO.sendAllNotifications(VENDOR_NAME_SCS, true, true, true);
      AdaptorDAO.sendAllNotifications(VENDOR_NAME_SCK, true, true, true);
      AdaptorDAO.sendAllNotifications(VENDOR_NAME_SCC, true, true, true);
      AdaptorDAO.sendAllNotifications(VENDOR_NAME_SCM, true, true, true);


       int adaptor_id = AdaptorRunInfo.getLastRunAdaptorId( STATSAdaptor.ADAPTOR_NAME, CONSTANT_ADAPTOR);

        // Update Adaptor_Run_Info table
        try
        {
            if ( success == true )
            {
                AdaptorRunInfo.saveAdaptorLastUpdatedStatus(CONSTANT_PARSER, STATSAdaptor.ADAPTOR_NAME, CONSTANT_SUCCESS, adaptor_id);
                System.out.println( "SUCCESSFULLY UPDATED IN THE DATABASE" );
            }
        }
        catch ( ScalarException se )
        {
            success = false; //As filES DATA SAVED , UPDATEING AS SUCCESS
            AdaptorRunInfo.saveAdaptorLastUpdatedStatus(CONSTANT_PARSER, STATSAdaptor.ADAPTOR_NAME, CONSTANT_SUCCESS, adaptor_id);
            log( "WARNING!! WARNING!! WARNING!! Could not update Adaptor run information, Exception: " + se );
            throw se;
        }
        // Move the successful files to 'done' directory
       if ( success )
       {
           AdaptorUtils.moveFilesToDone( successFileList, doneDestDir );
       }
    }
    /**
     *
     * @param fileName
     * @return
     * @throws Exception
     */
    private ArrayList<STATSWipStatus> parseTurnKeyWipReport( String fileName ) throws Exception
    {
        if ( fileName == null ) throw new ScalarException( "Filename argument is null" );

        ArrayList<STATSWipStatus> wipList              = new ArrayList<STATSWipStatus>();
        String line                     = null;

        try
        {
            File detailWipFile = new File( fileName );
            if ( detailWipFile.exists() == false )
            {
                throw new ScalarException( fileName + " doesnt exist" );
            }

            log( "\nFound " + fileName );
            log( "\nParsing the file for STATS Wip Inventory Report..." );
            System.out.println( "\nFound " + fileName );
            System.out.println( "\nParsing the file for STATS Wip Inventory Report..." );

            BufferedReader reader = new BufferedReader( new FileReader( detailWipFile ) );
            reader.readLine();  // Read out <Header Info > Line

            while ( ( line = reader.readLine() ) != null  && line.length() > 0 )
            {
                STATSWipStatus wipStatus = new STATSWipStatus();

                //line = line.replaceAll( "\"", "" );
                //System.out.println("line.split= " + line.split( "," ).length );
                String[] token = line.split( "\"," );
                String[] temparray = null;
                int count = -1;

                for (int x = 0; x < token.length; x++)
                {
                    if (token[x] != null && token[x].trim().length() > 0)
                    {                           
                        if ( token[x].trim().charAt(0) != '"' )
                        {
                            if ( token[x].indexOf("\"") != -1 )
                            {
                                token[x] = token[x].substring(0, token[x].indexOf("\"")) + token[x].substring(token[x].indexOf("\""), token[x].length()).replaceAll(",", "");
                            }
                            temparray = token[x].split(",");
                        }
                        else
                        {
                            temparray = new String[]{token[x]};
                        }

                        for (int y = 0; y < temparray.length; y++)
                        {
                            temparray[y] = temparray[y].replaceAll("\"", "").trim();
                            count++;

                            if ( temparray[y].length() > 0)
                            {
                                switch (count)
                                {
                                    //0,1 not required
                                    case 2:
                                            wipStatus.setDeviceName( temparray[y] );
                                            break;
                                    case 3:
                                            wipStatus.setMesLotId( temparray[y] );
                                            break;
                                    case 4:
                                            wipStatus.setWaferLotId( temparray[y] );
                                            break;
                                    case 5:
                                            wipStatus.setFabLotNo( temparray[y] );
                                            break;
                                    case 6:
                                            wipStatus.setDieOrWafer( temparray[y] );
                                            break;
                                    case 7:
                                            wipStatus.setLotType( temparray[y]);
                                            break;
                                    case 8:
                                            wipStatus.setCurrmainQty( temparray[y]);
                                            break;
                                   case 9:
                                            wipStatus.setMesPartName( temparray[y]);
                                            break;
                                    case 10:
                                            wipStatus.setProdArea( temparray[y]);
                                            break;
                                    case 11:
                                            wipStatus.setLocation ( temparray[y]);
                                            break;
                                    case 12:
                                            wipStatus.setStageName( temparray[y] );
                                            break;
                                    case 13:
                                            wipStatus.setStageNameDesc ( temparray[y]);
                                            break;
                                    case 14:
                                            wipStatus.setLotReceiveDate(temparray[y]);
                                            break;
                                    case 15:
                                            wipStatus.setState( temparray[y] );
                                            break;
                                    case 16:
                                           wipStatus.setLotStartDate(temparray[y]);
                                           break;
                                    case 17:
                                            wipStatus.setHoldCode( temparray[y]);
                                            break;
                                    case 18:
                                            wipStatus.setHoldReason( temparray[y]);
                                            break;
                                    //19, 20
                                    case 21:
                                            wipStatus.setPkgType( temparray[y]);
                                            break;
                                    case 22:
                                            wipStatus.setLeadCount( temparray[y]);
                                            break;
                                    //23,24,25,26,27,28,29,30
                                    case 31:
                                            wipStatus.setDateCode(temparray[y]);
                                            break;
                                    //32,33,34,35,36,37
                                    case 38:
                                            wipStatus.setSmLotId(temparray[y]);
                                            break;
                                     case 39:
                                            wipStatus.setSmCreationTime(temparray[y]);
                                            break;
                                    //39,40,41,42,43

                                    case 44:
                                            wipStatus.setPlant(temparray[y]);
                                            break;
                                    //45,46,47,48,49,50,51

                                    case 52:
                                            wipStatus.setCrd(temparray[y]);
                                            break;
                                    case 53:
                                            wipStatus.setCsd( temparray[y] );
                                            break;
                                    case 54:
                                            wipStatus.setOsd( temparray[y] );
                                            break;
                                    case 55:
                                            wipStatus.setLotStatus(temparray[y]);
                                            break;
                                    case 56:
                                            wipStatus.setCurrWaferQty(temparray[y]);
                                            break;
                                    case 57:
                                            wipStatus.setCurrDieQty(temparray[y]);
                                            break;
                                    //58,60 not required
                                  case 59:
                                        wipStatus.setPoNumber( temparray[y] );
                                        break;
                                 }
                            }
                        }
                    }

                }
                if ( count == 60 )
                {
                    if ( wipStatus.getDeviceName() != null && wipStatus.getDeviceName().length() > 0 )
                    {
                        wipList.add( wipStatus );
                    }
                }
                else
                {
                    System.out.println("!!!ERROR!!!ERROR While parsing the line = " + line );
                }
            }

            try
            {
                if ( reader != null )
                {
                   reader.close();
                }
            }
            catch(IOException ignore)
            {

            }

        }
        catch ( Exception ex )
        {   System.out.println("ERROR!!!ERROR!!! While Parsing the STATS Turnkey Wip Report");
            ex.printStackTrace();
            throw ex;
        }

        return wipList;

    } // end of prase Turnkey Wip Report method

    /**
     *
     * @param fileName
     * @return
     * @throws Exception
     */
    private ArrayList<STATSWipStatus> parseDropShipmentReport( String fileName ) throws Exception
    {
        if ( fileName == null ) throw new ScalarException( "Filename argument is null" );

        ArrayList<STATSWipStatus> dropShipList      = new ArrayList<STATSWipStatus>();
        String line             = null;
        String partNumber       = null;
        try
        {
            File detailShipFile = new File( fileName );
            if ( detailShipFile.exists() == false )
            {
                throw new ScalarException( fileName + " doesnt exist" );
            }

            log( "\nFound " + fileName );
            log( "\nParsing the file for Shipment Report..." );
            System.out.println( "\nFound " + fileName );
            System.out.println( "\nParsing the file for Shipment Report..." );

            BufferedReader reader = new BufferedReader( new FileReader( detailShipFile ) );
            reader.readLine();  // Read out <Header Info > Line
            reader.readLine();
            reader.readLine();
            reader.readLine();
            reader.readLine();
            while ( ( line = reader.readLine() ) != null  && line.length() > 0 )
            {
                STATSWipStatus dropShipStatus = new STATSWipStatus();

                line = line.replaceAll( "\"", "" );
                String[] token = line.split( "," );

                for (int x = 0; x < token.length; x++)
                {
                    if (token[x] != null && token[x].trim().length() > 0)
                    {
                        switch (x)
                        {
                           case 0:
									dropShipStatus.setLocation( token[x].trim() );
                                    break;
                           case 1:
                                    partNumber = token[x].trim();
									dropShipStatus.setDeviceName( partNumber );
                                    break;
                            //1
                            case 3:
									dropShipStatus.setDeviceName( partNumber );
                                    dropShipStatus.setFabLotNo( token[x].trim() );
                                    break;
                            case 4:
                                    dropShipStatus.setDateCode( token[x].trim() );
                                    break;
                            case 5:
                                    dropShipStatus.setCurrDieQty( token[x].trim());
                                    break;
							//5
							case 7:
									
                                    dropShipStatus.setAge( Math.round( Float.parseFloat(token[x].trim() ) ) );
                                    break;
                            //7,8,9,10

                         }

                    }

                }
                if ( dropShipStatus.getDeviceName() != null && dropShipStatus.getDeviceName().length() > 0
                        && dropShipStatus.getFabLotNo() != null && dropShipStatus.getFabLotNo().length() > 0 )
                {
                    dropShipList.add( dropShipStatus );
                }

            }

            try
            {
                if ( reader != null )
                {
                   reader.close();
                }
            }
            catch(IOException ignore)
            {

            }

        }
        catch ( Exception ex )
        {   System.out.println("ERROR!!!ERROR!!! While Parsing the STATS DROP Shipment Report");
            ex.printStackTrace();
            throw ex;
        }

        return dropShipList;

    } // end of prase DROP Shipment Report method


    private ArrayList<STATSWipStatus> parseSCSTransactionReport( String fileName ) throws Exception
    {
        if ( fileName == null ) throw new ScalarException( "Filename argument is null" );

        ArrayList<STATSWipStatus> shipLotsList  = new ArrayList<STATSWipStatus>();
        String line             = null;
        try
        {
            File detailShipFile = new File( fileName );
            if ( detailShipFile.exists() == false )
            {
                throw new ScalarException( fileName + " doesnt exist" );
            }

            log( "\nFound " + fileName );
            log( "\nParsing the file for Transaction Shipment Report..." );
            System.out.println( "\nFound " + fileName );
            System.out.println( "\nParsing the file for Transaction Shipment Report..." );

            BufferedReader reader = new BufferedReader( new FileReader( detailShipFile ) );
            reader.readLine();  // Read out <Header Info > Line
            reader.readLine();
            reader.readLine();

            while ( ( line = reader.readLine() ) != null  && line.length() > 0 )
            {
                STATSWipStatus shipStatus = new STATSWipStatus();

                line = line.replaceAll( "\"", "" );
                String[] token = line.split( "," );

                for (int x = 0; x < token.length; x++)
                {
                    if (token[x] != null && token[x].trim().length() > 0)
                    {
                        switch (x)
                        {
                            //0,1,2
                            case 3:
                                    shipStatus.setProdArea( token[x].trim() );
                                    break;

                            case 4:
									shipStatus.setDeviceName( token[x].trim() );
                                    break;
                            //5
                            case 6:
                                    shipStatus.setSmLotId( token[x].trim() );
                                    break;
                            case 7:
                                    shipStatus.setFabLotNo(token[x].trim() );
                                    break;
							case 8:
                                    shipStatus.setCurrWaferQty ( token[x].trim() );
                                    break;
                            case 9:
                                    shipStatus.setCurrDieQty ( token[x].trim() );
                                    break;
                            case 10:
                                    shipStatus.setLotStartDate ( StringUtils.formatDate(token[x].trim(), "dd-MMM-yyyy", "MM/dd/yyyy" ) );
                                    break;
                            case 11:
                                   shipStatus.setDateCode (token[x].trim());
                                   break;
                            case 12:
                                   shipStatus.setLotType (token[x].trim() );
                                   break;
                         }
                     }
                }
                if ( shipStatus.getDeviceName() != null && shipStatus.getDeviceName().length() > 0
                        && shipStatus.getFabLotNo() != null && shipStatus.getFabLotNo().length() > 0 )
                {
                    shipLotsList.add( shipStatus );
                }
             }

            try
            {
                if ( reader != null )
                {
                   reader.close();
                }
            }
            catch(IOException ignore)
            {

            }

        }
        catch ( Exception ex )
        {   System.out.println("ERROR!!!ERROR!!! While Parsing the STATS Transaction Shipment Report");
            ex.printStackTrace();
            throw ex;
        }

        return shipLotsList;

    } // end of prase Transaction Report method
    /**
     *
     * @param fileName
     * @throws Exception
     */
    private void parseAllWipReport( String fileName ) throws Exception
    {
        if ( fileName == null ) throw new ScalarException( "Filename argument is null" );

        ParserResult result            = null;
        TestLot testLot         = null;
        InventoryLot inventoryLot = null;
        AssemblyLot  assemblyLot  = null;
        FabSortLot fabSortLot     = null;
        String lotNumber        = null;
        String partNumber       = null;
        String fablotNumber     = null;
        String vendor			= null;

        try
        {
            File fabWipFile = new File( fileName );
            if ( fabWipFile.exists() == false )
            {
                throw new ScalarException( fileName + " doesnt exist" );
            }

            log( "\nFound " + fileName );
            log( "\nParsing the file for Wip Report..." );
            System.out.println( "\nFound " + fileName );
            System.out.println( "\nParsing the file for Wip Report..." );
            Parser parser = ParserFactory.getCSVParser( fabWipFile, ',' );

            ((CSVParserImpl)parser).setHeaderRowIdx(0);
            ((CSVParserImpl)parser).setDataStartRowIdx(1);

            result = parser.parse();

            while (result.next())
            {
                fablotNumber    = result.getString("Customer Lot Number");
                partNumber      = result.getString("Customer Device");
                lotNumber       = result.getString("MES Lotid");

                if( result.getString("Plant") != null && result.getString("Plant").equalsIgnoreCase( "SCS" ) )
                {
                	vendor = VENDOR_NAME_SCS;
                }
                else if ( result.getString("Plant") != null &&  result.getString("Plant").equalsIgnoreCase( "SCK" ) )
                {
                	vendor = VENDOR_NAME_SCK;
                }
                else if (result.getString("Plant") != null &&  result.getString("Plant").equalsIgnoreCase( "SCC" ) )
                {
                	vendor = VENDOR_NAME_SCC;
                }
                else if	( result.getString("Plant") != null &&  result.getString("Plant").equalsIgnoreCase( "SCM" ) )
                {
                	vendor = VENDOR_NAME_SCM;
                }

                if ( fablotNumber == null )
                {
                    fablotNumber = result.getString("Wafer Lotid");
                }
                if( lotNumber == null )
                {
                    lotNumber = fablotNumber;
                }

                String lotStatus = null;
                String lotCategory = null;
                if( result.getString("State") != null && ( "WAIT".equalsIgnoreCase( result.getString("State") )
                        || "HELD".equalsIgnoreCase( result.getString("State") ) || result.getString("State").indexOf("HLD") != -1 ) )
                {
                    lotStatus = LOT_STATUS_HOLD;
                }
                else
                {
                    lotStatus = LOT_STATUS_RUNNING;
                }
                if ( "ENG".equalsIgnoreCase( result.getString("LotType") ) || "QUAL".equalsIgnoreCase(result.getString("LotType"))
                                || "EG".equalsIgnoreCase( result.getString("LotType") ) || "QL".equalsIgnoreCase(result.getString("LotType")) )
                {
                    lotCategory = LOT_CATEGORY_TYPE_ENGG;
                }
                else
                {
                    lotCategory = LOT_CATEGORY_TYPE_PROD;
                }
                String dateIn = null;
                String expectedDateOut = null;
                if ( result.getString("Stateentrytime") != null )
                {
                     dateIn = StringUtils.formatDate(result.getString("Stateentrytime"),"dd-MMM-yy", "MM/dd/yyyy" );
                }
                else if ( result.getString("Stagestarttime") != null )
                {
                     dateIn = StringUtils.formatDate(result.getString("Stagestarttime"),"dd-MMM-yy", "MM/dd/yyyy" );
                }
                else if ( result.getString("Sm Createtime") != null )
                {
                     dateIn = StringUtils.formatDate(result.getString("Sm Createtime"),"dd-MMM-yy", "MM/dd/yyyy" );
                }

                if ( result.getString("CRD") != null )
                {
                     expectedDateOut = StringUtils.formatDate(result.getString("CRD"),"dd-MMM-yy", "MM/dd/yyyy" );
                }
                else if ( result.getString("CSD") != null )
                {
                     expectedDateOut = StringUtils.formatDate(result.getString("CSD"),"dd-MMM-yy", "MM/dd/yyyy" );
                }
                else if ( result.getString("OSD") != null )
                {
                     expectedDateOut = StringUtils.formatDate(result.getString("OSD"),"dd-MMM-yy", "MM/dd/yyyy" );
                }
                
                if ( lotNumber != null && lotNumber.trim().length() > 0 && partNumber != null && partNumber.trim().length() > 0)
                {
                    if ( lotNumber.endsWith("0000") || lotNumber.endsWith("P000"))
                    {
                        if ( lotNumber.indexOf("0000") > 0 )
                        {
                            lotNumber = lotNumber.substring(0, lotNumber.indexOf("0000") );
                        }
                        else if ( lotNumber.indexOf("P000") > 0 )
                        {
                            lotNumber = lotNumber.substring(0, lotNumber.indexOf("P000") );
                        }
                        fablotNumber = result.getString("Wafer Lotid");
                        if ( fablotNumber == null )
                        {
                            fablotNumber = result.getString("Customer Lot Number");
                        }
                    }
                    if ( fablotNumber != null && fablotNumber.trim().length() > 0 )
                    {
                          fablotNumber = fablotNumber.split("     ")[0];
                    }
                    //SORT
                    if (result.getString("Production Area") != null && "SORT".equalsIgnoreCase( result.getString("Production Area") ) )
                    {
                    	//log( lotNumber +" In Sort");
                        if ( partNumber.endsWith("-00") )
                        {
                            partNumber = partNumber.substring(0, partNumber.lastIndexOf("-00") );
                        }
                        fablotNumber = result.getString("Wafer Lotid");
                        if ( fablotNumber == null )
                        {
                            fablotNumber = result.getString("Customer Lot Number");
                        }
                        fabSortLot = m_sortDataMap.get(partNumber + fablotNumber );

                        if ( fabSortLot == null )
                        {
                            fabSortLot = new FabSortLot( vendor, WIP_TYPE_SORT);
                            m_sortDataMap.put( partNumber+ fablotNumber, fabSortLot);
                        }
                        int wquantity =0;
                        if (fabSortLot.getQtyIn() != null)
                        {
                            try
                            {
                                wquantity = Integer.parseInt(fabSortLot.getQtyIn());
                            }
                            catch (NumberFormatException ignore) {
                            }
                            wquantity += result.getInt("Current Wafer Qty SUM");
                        }
                        else
                        {
                            wquantity = result.getInt("Current Wafer Qty SUM");
                        }
                        if (wquantity > 0 && wquantity < 26 )
                        {
                            fabSortLot.setQtyIn( wquantity+"" );
                            fabSortLot.setLotId( fablotNumber );
                            fabSortLot.setCustProduct( partNumber );
                            fabSortLot.setLotStatus( lotStatus);
                            fabSortLot.setFabLotNumber( fablotNumber );
                            fabSortLot.setPsType( LOCATION_TYPE_SORT );
                            fabSortLot.setStage( result.getString("Stage Description") );
                            fabSortLot.setLotCategory( lotCategory );
                            fabSortLot.setDateIn( dateIn );
                            fabSortLot.setPoNumber( result.getString("PO Number") );
                            fabSortLot.setForcastedDateOut( expectedDateOut );
                        }
                    }
                    //DIE BANK
                    if (result.getString("Production Area") != null && "VWAREHOUSE".equalsIgnoreCase( result.getString("Production Area") )
                            && "W-WFRBANK".equalsIgnoreCase( result.getString("Location") ) )
                    {
                    	//log( lotNumber +" In Die Bank");
                        if ( partNumber.endsWith("-00") )
                        {
                            partNumber = partNumber.substring(0, partNumber.lastIndexOf("-00") );
                        }
                        fablotNumber = result.getString("Wafer Lotid");
                        if ( fablotNumber == null )
                        {
                            fablotNumber = result.getString("Customer Lot Number");
                        }
                        inventoryLot = (InventoryLot)m_dieBankDataMap.get( partNumber + fablotNumber );

                        if ( inventoryLot == null )
                        {
                            inventoryLot = new InventoryLot( vendor, LOCATION_TYPE_DIE_BANK );
                            m_dieBankDataMap.put( partNumber + fablotNumber, inventoryLot );
                        }

                        int quantity = 0;
                        int wquantity =0;
                        if (inventoryLot.getQtyIn() != null)
                        {
                            try
                            {
                                quantity = Integer.parseInt(inventoryLot.getQtyIn());
                                wquantity = Integer.parseInt(inventoryLot.getWaferQtyIn());
                            }
                            catch (NumberFormatException ignore) {
                            }
                            quantity += result.getInt("Current Die Qty SUM");
                            wquantity += result.getInt("Current Wafer Qty SUM");
                        }
                        else
                        {
                            quantity = result.getInt("Current Die Qty SUM");
                            wquantity = result.getInt("Current Wafer Qty SUM");
                        }
                        if (quantity > 0 )
                        {
                            inventoryLot.setPartNumber( partNumber );
                            inventoryLot.setLotNumber( fablotNumber );
                            inventoryLot.setQtyIn(quantity + "");
                            inventoryLot.setWaferQtyIn(wquantity + "");
                            inventoryLot.setDateIn( dateIn );
                            inventoryLot.setFabLotNumber( fablotNumber );
                            inventoryLot.setPkgType( result.getString("Package")  );
                            inventoryLot.setLeadCount( result.getString("Leadcount") );
                            inventoryLot.setStatus( lotStatus );
                            inventoryLot.setLotCategory( lotCategory );
                            inventoryLot.setDateCode(result.getString("Datecode"));
                        }
                    }
                    //DIE BANK
                    if (result.getString("Production Area") != null && ( "Die-Bank".equalsIgnoreCase( result.getString("Production Area") ) || "DieBank".equalsIgnoreCase( result.getString("Production Area")) ) )
                    {
                        //log( lotNumber +" In Die Bank");
                        if ( partNumber.endsWith("-00") )
                        {
                            partNumber = partNumber.substring(0, partNumber.lastIndexOf("-00") );
                        }
                        fablotNumber = result.getString("Wafer Lotid");
                        if ( fablotNumber == null )
                        {
                            fablotNumber = result.getString("Customer Lot Number");
                        }
                        inventoryLot = (InventoryLot)m_dieBankDataMap.get( partNumber + fablotNumber );

                        if ( inventoryLot == null )
                        {
                            inventoryLot = new InventoryLot( vendor, LOCATION_TYPE_DIE_BANK );
                            m_dieBankDataMap.put( partNumber + fablotNumber, inventoryLot );
                        }

                        int quantity = 0;
                        int wquantity = 0;
                        if (inventoryLot.getQtyIn() != null)
                        {
                            try
                            {
                                quantity = Integer.parseInt(inventoryLot.getQtyIn());
                                wquantity = Integer.parseInt(inventoryLot.getWaferQtyIn());
                            }
                            catch (NumberFormatException ignore) {
                            }
                            quantity += result.getInt("Current Die Qty SUM");
                                wquantity += result.getInt("Current Wafer Qty SUM");
                        }
                        else
                        {
                            quantity = result.getInt("Current Die Qty SUM");
                            wquantity = result.getInt("Current Wafer Qty SUM");
                        }
                        
                        if (quantity > 0 )
                        {
                            inventoryLot.setPartNumber( partNumber );
                            inventoryLot.setLotNumber( fablotNumber );
                            inventoryLot.setQtyIn(quantity + "");
                            inventoryLot.setWaferQtyIn( wquantity + "");
                            inventoryLot.setDateIn( dateIn );
                            inventoryLot.setFabLotNumber( fablotNumber );
                            inventoryLot.setPkgType( result.getString("Package") );
                            inventoryLot.setLeadCount( result.getString("Leadcount") );
                            inventoryLot.setStatus( lotStatus );
                            inventoryLot.setLotCategory( lotCategory );
                            inventoryLot.setDateCode( result.getString("Datecode") );
                        }
                    }
                    //DIE BANK
                    if (result.getString("Production Area") != null && "ASSEMBLY".equalsIgnoreCase( result.getString("Production Area") )
                            && "W".equalsIgnoreCase( result.getString("(D)ie/(W)afer") ) )
                    {
                        //log( lotNumber +" In Die Bank");
                        if ( partNumber.endsWith("-00") )
                        {
                            partNumber = partNumber.substring(0, partNumber.lastIndexOf("-00") );
                        }
                        fablotNumber = result.getString("Wafer Lotid");
                        if ( fablotNumber == null )
                        {
                            fablotNumber = result.getString("Customer Lot Number");
                        }
                        inventoryLot = (InventoryLot)m_dieBankDataMap.get( partNumber + fablotNumber );

                        if ( inventoryLot == null )
                        {
                            inventoryLot = new InventoryLot( vendor, LOCATION_TYPE_DIE_BANK );
                            m_dieBankDataMap.put( partNumber + fablotNumber, inventoryLot );
                        }

                        int quantity = 0;
                        int wquantity = 0;
                        if (inventoryLot.getQtyIn() != null)
                        {
                            try
                            {
                                quantity = Integer.parseInt(inventoryLot.getQtyIn());
                                wquantity = Integer.parseInt(inventoryLot.getWaferQtyIn());
                            }
                            catch (NumberFormatException ignore) {
                            }
                                quantity += result.getInt("Current Die Qty SUM");
                                wquantity += result.getInt("Current Wafer Qty SUM");
                        }
                        else
                        {
                            quantity = result.getInt("Current Die Qty SUM");
                            wquantity = result.getInt("Current Wafer Qty SUM");
                        }
                        if (quantity > 0 )
                        {
                            inventoryLot.setPartNumber( partNumber );
                            inventoryLot.setLotNumber( fablotNumber );
                            inventoryLot.setQtyIn(quantity + "");
                            inventoryLot.setWaferQtyIn( wquantity +"");
                            inventoryLot.setDateIn( dateIn );
                            inventoryLot.setFabLotNumber( fablotNumber );
                            inventoryLot.setPkgType( result.getString("Package") );
                            inventoryLot.setLeadCount( result.getString("Leadcount"));
                            inventoryLot.setStatus( lotStatus );
                            inventoryLot.setStage( result.getString("Stage Description") );
                            inventoryLot.setLotCategory( lotCategory );
                            inventoryLot.setDateCode( result.getString("Datecode") );
                        }
                    }

                    //SCS ASSEMBLY
                    if (  result.getString("Production Area")  != null && "ASSEMBLY".equalsIgnoreCase(result.getString("Production Area") )
                            && "D".equalsIgnoreCase( result.getString("(D)ie/(W)afer")) )
                   {
                        if ("L-2NDOPT".equalsIgnoreCase( result.getString("Stage") )  || "L-2NDOPT".equalsIgnoreCase( result.getString("Location") ))
                        {
                            log( lotNumber +" In Die Bank");
                            if ( partNumber.endsWith("-00") )
                            {
                                partNumber = partNumber.substring(0, partNumber.lastIndexOf("-00") );
                            }
                            fablotNumber = result.getString("Wafer Lotid");
                            if ( fablotNumber == null )
                            {
                                fablotNumber = result.getString("Customer Lot Number");
                            }
                            inventoryLot = (InventoryLot)m_dieBankDataMap.get( partNumber + fablotNumber );

                            if ( inventoryLot == null )
                            {
                                inventoryLot = new InventoryLot( vendor, LOCATION_TYPE_DIE_BANK );
                                m_dieBankDataMap.put( partNumber + fablotNumber, inventoryLot );
                            }

                            int quantity = 0;
                            int wquantity = 0;
                            if (inventoryLot.getQtyIn() != null)
                            {
                                try
                                {
                                    quantity = Integer.parseInt(inventoryLot.getQtyIn());
                                    wquantity = Integer.parseInt(inventoryLot.getWaferQtyIn());
                                }
                                catch (NumberFormatException ignore) {
                                }
                                quantity += result.getInt("Current Die Qty SUM");
                                wquantity += result.getInt("Current Wafer Qty SUM");
                            }
                            else
                            {
                                quantity = result.getInt("Current Die Qty SUM");
                                wquantity = result.getInt("Current Wafer Qty SUM");
                            }
                            if (quantity > 0 )
                            {
                                inventoryLot.setPartNumber( partNumber );
                                inventoryLot.setLotNumber( fablotNumber );
                                inventoryLot.setQtyIn(quantity + "");
                                inventoryLot.setWaferQtyIn( wquantity +"");
                                inventoryLot.setDateIn( dateIn );
                                inventoryLot.setFabLotNumber( fablotNumber );
                                inventoryLot.setPkgType( result.getString("Package") );
                                inventoryLot.setLeadCount( result.getString("Leadcount") );
                                inventoryLot.setStatus( lotStatus );
                                inventoryLot.setStage( result.getString("Stage Description") );
                                inventoryLot.setLotCategory( lotCategory );
                                inventoryLot.setDateCode( result.getString("Datecode") );
                            }
                        }
                        else
                        {
                            //log( "In Assembly" + lotNumber ) ;

                            assemblyLot = (AssemblyLot) m_assyDataMap.get( partNumber + lotNumber + fablotNumber );
                            if (assemblyLot == null)
                            {
                                assemblyLot = new AssemblyLot( vendor, WIP_TYPE_ASSEMBLY );
                                m_assyDataMap.put( partNumber + lotNumber + fablotNumber, assemblyLot);
                            }
                            int quantity = 0;
                            if (assemblyLot.getQtyIn() != null)
                            {
                                try
                                {
                                    quantity = Integer.parseInt(assemblyLot.getQtyIn());
                                }
                                catch (NumberFormatException ignore) {
                                }
                                quantity += result.getInt("Current Die Qty SUM");
                            }
                            else
                            {
                                quantity = result.getInt("Current Die Qty SUM");
                            }

                            if ( quantity > 0 )
                            {
                                assemblyLot.setLotNumber( lotNumber );
                                assemblyLot.setDeviceName( partNumber );
                                assemblyLot.setStatus(lotStatus);
                                assemblyLot.setHoldReason( result.getString("Holdreason") );
                                assemblyLot.setHoldCode(result.getString("Holdcode"));
                                assemblyLot.setPONumber(  result.getString("PO Number"));
                                assemblyLot.setFabLotNumber( fablotNumber );
                                assemblyLot.setPackageType(result.getString("Package") );
                                assemblyLot.setCategory( lotCategory );
                                assemblyLot.setLeadCount( result.getString("Leadcount"));
                                assemblyLot.setDateIn( dateIn );
                                assemblyLot.setExpectedDateOut( expectedDateOut );
                                assemblyLot.setStage( result.getString("Stage Description") );
                                assemblyLot.setQtyIn( quantity+"" );
                                assemblyLot.setDateCode( result.getString("Datecode") );
                            }
                        }//end of else Block
                    }
                    //SCK ASSEMBLY
                    if (  result.getString("Production Area") != null && !"WFRS".equalsIgnoreCase(result.getString("Package") )
                            && ("ASSY".equalsIgnoreCase( result.getString("Production Area") ) || "FGS".equalsIgnoreCase( result.getString("Production Area") )
                                    || "BACKGRIND".equalsIgnoreCase( result.getString("Production Area") ) ) )
                    {
                        //log( "In Assembly" + lotNumber ) ;

                        assemblyLot = (AssemblyLot) m_assyDataMap.get( partNumber + lotNumber + fablotNumber );
                        if (assemblyLot == null)
                        {
                            assemblyLot = new AssemblyLot( vendor, WIP_TYPE_ASSEMBLY );
                            m_assyDataMap.put( partNumber + lotNumber + fablotNumber, assemblyLot);
                        }
                        int quantity = 0;
                        if (assemblyLot.getQtyIn() != null)
                        {
                            try
                            {
                                quantity = Integer.parseInt(assemblyLot.getQtyIn());
                            }
                            catch (NumberFormatException ignore) {
                            }
                            quantity += result.getInt("Current Die Qty SUM");
                        }
                        else
                        {
                            quantity = result.getInt("Current Die Qty SUM");
                        }

                        if ( quantity > 0 )
                        {
                            assemblyLot.setLotNumber( lotNumber );
                            assemblyLot.setDeviceName( partNumber );
                            assemblyLot.setStatus(lotStatus);
                            assemblyLot.setHoldReason( result.getString("Holdreason") );
                            assemblyLot.setHoldCode( result.getString("Holdcode") );
                            assemblyLot.setPONumber(  result.getString("PO Number") );
                            assemblyLot.setFabLotNumber( fablotNumber );
                            assemblyLot.setPackageType( result.getString("Package") );
                            assemblyLot.setCategory( lotCategory );
                            assemblyLot.setLeadCount( result.getString("Leadcount") );
                            assemblyLot.setDateIn( dateIn );
                            assemblyLot.setExpectedDateOut( expectedDateOut );
                            assemblyLot.setStage( result.getString("Stage Description") );
                            assemblyLot.setQtyIn( quantity+"" );
                            assemblyLot.setDateCode( result.getString("Datecode"));
                        }
                    }
                    //CLASS STORE
                    if (result.getString("Production Area") != null && ( ( "VWAREHOUSE".equalsIgnoreCase( result.getString("Production Area") ) && "W-TSTBANK".equalsIgnoreCase( result.getString("Location") ) )
															 || ( "Test".equalsIgnoreCase( result.getString("Production Area") ) && "T-BATCH".equalsIgnoreCase( result.getString("Location") ) ) ) )
                    {
                        //log( lotNumber +" In Pre Test");

                        inventoryLot = (InventoryLot)m_preTestDataMap.get( partNumber + fablotNumber );

                        if ( inventoryLot == null )
                        {
                            inventoryLot = new InventoryLot( vendor, LOCATION_TYPE_PRE_TEST );
                            m_preTestDataMap.put( partNumber + fablotNumber, inventoryLot );
                        }

                        int quantity = 0;
                        if (inventoryLot.getQtyIn() != null)
                        {
                            try
                            {
                                quantity = Integer.parseInt(inventoryLot.getQtyIn());
                            }
                            catch (NumberFormatException ignore) {
                            }
                            quantity += result.getInt("Current Die Qty SUM");
                        }
                        else
                        {
                            quantity = result.getInt("Current Die Qty SUM");
                        }
                        if (quantity > 0 )
                        {
                            inventoryLot.setPartNumber( partNumber );
                            inventoryLot.setLotNumber( fablotNumber );
                            inventoryLot.setQtyIn(quantity + "");
                            inventoryLot.setDateIn( dateIn );
                            inventoryLot.setFabLotNumber( fablotNumber );
                            inventoryLot.setPkgType( result.getString("Package") );
                            inventoryLot.setLeadCount( result.getString("Leadcount") );
                            inventoryLot.setStatus( lotStatus );
                            inventoryLot.setStage( result.getString("Stage Description") );
                            inventoryLot.setLotCategory( lotCategory );
                            inventoryLot.setDateCode( result.getString("Datecode") );
                        }
                    }
                    // FT Process

                   if ( result.getString("Production Area") != null && ( ( "TEST".equalsIgnoreCase( result.getString("Production Area") ) && !"T-BATCH".equalsIgnoreCase( result.getString("Location") ) ) || "IC.TEST".equalsIgnoreCase( result.getString("Production Area") ) ) )
                    {
                        //log(lotNumber + "In Test FT");

                        testLot = (TestLot) m_ftDataMap.get( partNumber + lotNumber + fablotNumber );
                        if (testLot == null)
                        {
                            testLot = new TestLot( vendor, LOCATION_TYPE_FT );
                            m_ftDataMap.put(partNumber + lotNumber + fablotNumber, testLot);
                        }

                        int quantity = 0;
                        if (testLot.getQtyIn() != null)
                        {
                            try
                            {
                                quantity = Integer.parseInt(testLot.getQtyIn());
                            }
                            catch (NumberFormatException ignore) {
                            }
                            quantity += result.getInt("Current Die Qty SUM");
                        }
                        else
                        {
                            quantity = result.getInt("Current Die Qty SUM");
                        }
                        
                        if ( quantity > 0 )
                        {
                            testLot.setPartNumber( partNumber );
                            testLot.setLotNumber( lotNumber );
                            testLot.setFabLotNumber( fablotNumber );
                            testLot.setDateIn( dateIn );
                            testLot.setExpecetedDate( expectedDateOut );
                            testLot.setStage( result.getString("Stage Description") );
                            testLot.setQtyIn( quantity + "");
                            testLot.setLeadCount( result.getString("Leadcount") );
                            testLot.setPackageType( result.getString("Package") );
                            testLot.setStatus(lotStatus);
                            testLot.setPoNumber(  result.getString("PO Number") );
                            testLot.setHoldReason( result.getString("Holdreason") );
                            testLot.setHoldCode( result.getString("Holdcode") );
                            testLot.setCategory( lotCategory );
                            testLot.setDateCode( result.getString("Datecode") );
                        }
                    }

                    // EOL Process
                    if ( result.getString("Production Area") != null && ( "POST-TEST".equalsIgnoreCase( result.getString("Production Area") )  || "FG".equalsIgnoreCase( result.getString("Production Area") ) || "IC.FGS".equalsIgnoreCase( result.getString("Production Area") ) ) )
                    {
                        //log(lotNumber + "In EOL");

                        inventoryLot = (InventoryLot) m_eolDataMap.get( partNumber + lotNumber + fablotNumber );
                        if (inventoryLot == null)
                        {
                            inventoryLot = new InventoryLot( vendor, LOCATION_TYPE_EOL);
                            m_eolDataMap.put(partNumber + lotNumber + fablotNumber, inventoryLot);
                        }

                       int quantity = 0;
                        if (inventoryLot.getQtyIn() != null)
                        {
                            try
                            {
                                quantity = Integer.parseInt(inventoryLot.getQtyIn());
                            }
                            catch (NumberFormatException ignore) {
                            }
                            quantity += result.getInt("Current Die Qty SUM");
                        }
                        else
                        {
                            quantity = result.getInt("Current Die Qty SUM");
                        }
                        if ( quantity > 0 )
                        {
                            inventoryLot.setPartNumber( partNumber );
                            inventoryLot.setLotNumber( lotNumber );
                            inventoryLot.setFabLotNumber( fablotNumber );
                            inventoryLot.setDateIn( dateIn );
                            inventoryLot.setExpectedDate( expectedDateOut );
                            inventoryLot.setStage( result.getString("Stage Description"));
                            inventoryLot.setQtyIn(quantity+"");
                            inventoryLot.setLeadCount( result.getString("Leadcount") );
                            inventoryLot.setPkgType( result.getString("Package") );
                            inventoryLot.setStatus(lotStatus);
                            inventoryLot.setHoldReason( result.getString("Holdreason") );
                            inventoryLot.setHoldCode( result.getString("Holdcode") );
                            inventoryLot.setCategory( lotCategory );
                            inventoryLot.setDateCode( result.getString("Datecode") );
                        }
                    }
                }
            }
        }
        catch( Exception e)
        {
            System.out.println(" !!ERROR !! ERROR Exception while get getting the STATS Wip Details");
            e.printStackTrace();
            throw e;
        }
    }

	private void getAllDropShippingDetails( ArrayList<STATSWipStatus> lotstatusList ) throws Exception
    {
        STATSWipStatus wipStatus = null;
        InventoryLot inventoryLot = null;
        String lotNumber        = null;
        String partNumber       = null;
        String fablotNumber     = null;

        if (lotstatusList == null)
        {
            return;
        }

        Iterator<STATSWipStatus> iterator = lotstatusList.iterator();
        try
        {
            while (iterator.hasNext())
            {
                wipStatus = (STATSWipStatus) iterator.next();

                fablotNumber    = wipStatus.getFabLotNo();
                partNumber      = wipStatus.getDeviceName();
                lotNumber       = wipStatus.getFabLotNo();

                String dateIn = null;
				Calendar calendar = Calendar.getInstance();
				calendar.add( Calendar.DATE, -wipStatus.getAge() );
                              
                dateIn = StringUtils.formatDateToString( calendar.getTime(), "MM/dd/yyyy" );
                				
                if ( lotNumber != null && lotNumber.trim().length() > 0 && partNumber != null && partNumber.trim().length() > 0)
                {
                    if (wipStatus.getLocation().equalsIgnoreCase(VENDOR_NAME_SCK ) )
                    {
                        //log("In FG " + lotNumber);
                        inventoryLot = (InventoryLot)m_sckfgDataMap.get( partNumber + lotNumber + fablotNumber);

                        if ( inventoryLot == null )
                        {
                            inventoryLot = new InventoryLot( VENDOR_NAME_SCK, LOCATION_TYPE_FG );
                            m_sckfgDataMap.put( partNumber + lotNumber + fablotNumber, inventoryLot );
                        }
                    }
                    else if (wipStatus.getLocation().equalsIgnoreCase("SCM" ) )
                    {
                        //log("In FG " + lotNumber);
                        inventoryLot = (InventoryLot)m_scmfgDataMap.get( partNumber + lotNumber + fablotNumber);

                        if ( inventoryLot == null )
                        {
                            inventoryLot = new InventoryLot( VENDOR_NAME_SCM, LOCATION_TYPE_FG );
                            m_scmfgDataMap.put( partNumber + lotNumber + fablotNumber, inventoryLot );
                        }
                    }
                    else
                    {
                        //log("In FG " + lotNumber);
                        inventoryLot = (InventoryLot)m_scsfgDataMap.get( partNumber + lotNumber + fablotNumber);

                        if ( inventoryLot == null )
                        {
                            inventoryLot = new InventoryLot( VENDOR_NAME_SCS, LOCATION_TYPE_FG );
                            m_scsfgDataMap.put( partNumber + lotNumber + fablotNumber, inventoryLot );
                        }
                    }

					int quantity = 0;
					if (inventoryLot.getQtyIn() != null)
					{
						try
						{
							quantity = Integer.parseInt(inventoryLot.getQtyIn());
						}
						catch (NumberFormatException ignore) {
						}
						try
						{
							quantity += Integer.parseInt(wipStatus.getCurrDieQty());
						}
						catch (NumberFormatException nfe) {
						}
					}
					else
					{
						try
						{
							quantity = Integer.parseInt( wipStatus.getCurrDieQty() );
						}
						catch (NumberFormatException ignore) {
						}
					}
					
					if (quantity > 0 )
					{
						inventoryLot.setPartNumber( partNumber );
						inventoryLot.setLotNumber( lotNumber );
						inventoryLot.setQtyIn(quantity + "");
						inventoryLot.setDateIn( dateIn );
						inventoryLot.setFabLotNumber( fablotNumber );
						inventoryLot.setDateCode( wipStatus.getDateCode() );
						inventoryLot.setStatus( LOT_STATUS_RUNNING );
						inventoryLot.setLotCategory( LOT_CATEGORY_TYPE_PROD );
					}
				}
            }
        }
        catch( Exception e)
        {
            System.out.println(" !!ERROR !! ERROR Exception while get getting the STATS Wip Details");
            e.printStackTrace();
            throw e;
        }
    }

    private void parseTransactionReport( String fileName ) throws Exception
    {
        if ( fileName == null ) throw new ScalarException( "Filename argument is null" );
        ParserResult result     = null;

        String lotNumber        = null;
        String partNumber       = null;
        String fablotNumber     = null;
        ShippedLot shippedLot   = null;
        AssemblyLot assemblyLot = null;
        String vendor           = null;
        try
        {
            File detailWipFile = new File( fileName );
            if ( detailWipFile.exists() == false )
            {
                throw new ScalarException( fileName + " doesnt exist" );
            }

            log( "\nFound " + fileName );
            log( "\nParsing the file for SCK,SCC,SCM Transaction Report..." );
            System.out.println( "\nFound " + fileName );
            System.out.println( "\nParsing the file for SCK,SCC, SCM Transaction Report..." );

            Parser parser = ParserFactory.getCSVParser( detailWipFile, ',' );

            ((CSVParserImpl)parser).setHeaderRowIdx(0);
            ((CSVParserImpl)parser).setDataStartRowIdx(1);

            result = parser.parse();

            //System.out.println("result.getString() = " + result.getHeadings() );

            while ( result.next() )
            {
                partNumber   = result.getString("Custdevice");
                fablotNumber = result.getString("Waferlotid");
                lotNumber    = result.getString("Lotid");
                if ( lotNumber == null)
                {
                    lotNumber = fablotNumber;
                }
                if ( fablotNumber == null )
                {
                    fablotNumber =  result.getString("Custlotnum");
                }
                if ( result.getString("Plant") != null &&  result.getString("Plant").equalsIgnoreCase( "SCK" ) )
                {
                	vendor = VENDOR_NAME_SCK;
                }
                else if ( result.getString("Plant") != null &&  result.getString("Plant").equalsIgnoreCase( "SCC" ) )
                {
                	vendor = VENDOR_NAME_SCC;
                }
                else if	( result.getString("Plant") != null &&  result.getString("Plant").equalsIgnoreCase( "SCM" ) )
                {
                	vendor = VENDOR_NAME_SCM;
                }

                if ( partNumber != null && partNumber.length() > 0 && lotNumber != null && lotNumber.length() > 0 && vendor != null )
                {
                    if ( lotNumber.endsWith("0000") )
                    {
                        lotNumber = lotNumber.substring(0, lotNumber.indexOf("0000") );
                    }
                    //FT SHIP
                   if ( result.getString("Process Stage") != null && "TEST_OUT".equalsIgnoreCase(result.getString("Process Stage").trim() ) )
                   {
                       //log("In FT Shippping " + lotNumber );
                       shippedLot = ( ShippedLot ) m_ftShipDataMap.get ( partNumber + lotNumber + fablotNumber + result.getString("Transaction Time") );

                       if ( shippedLot == null )
                       {
                            shippedLot = new ShippedLot(vendor, LOCATION_TYPE_TEST );
                            m_ftShipDataMap.put( partNumber + lotNumber + fablotNumber + result.getString("Transaction Time"), shippedLot );
                       }

                       int quantity = 0;
                       if ( shippedLot.getShipQty() != null )
                       {
                           try
                           {
                               quantity = Integer.parseInt( shippedLot.getShipQty() );
                           }
                           catch ( NumberFormatException ignore )
                           {
                               quantity = 0;
                           }

                           quantity += result.getInt("Dieqty");
                       }
                       else
                       {
                           quantity = result.getInt("Dieqty");
                       }

                       if ( quantity > 0 )
                       {
                           shippedLot.setLotNumber( lotNumber );
                           shippedLot.setPartNumber( partNumber );
                           shippedLot.setShipDate( StringUtils.formatDate(result.getString("Transaction Time"), "dd-MMM-yy HH:mm:ss", "MM/dd/yyyy HH:mm:ss" ) );

                           shippedLot.setShipQty( quantity + "" );
                           shippedLot.setFabLotNumber( fablotNumber );
                           shippedLot.setProcessType( LOCATION_TYPE_FT );
                       }
                   }

                   if ( result.getString("Process Stage") != null && "ASSEMBLY_IN".equalsIgnoreCase(result.getString("Process Stage").trim() ))
                   {
                       assemblyLot = (AssemblyLot) m_assyYieldMap.get( partNumber + fablotNumber + lotNumber );

                       if (assemblyLot == null)
                       {
                           assemblyLot = new AssemblyLot( vendor, LOCATION_TYPE_ASSEMBLY);
                           m_assyYieldMap.put( partNumber + fablotNumber + lotNumber , assemblyLot );
                       }

                       int assyQtyIn = 0;
                       if ( assemblyLot.getQtyIn() != null)
                       {
                           try
                           {
                               assyQtyIn = Integer.parseInt( assemblyLot.getQtyIn() );
                           }
                           catch ( NumberFormatException ignore )
                           {
                               assyQtyIn = 0;
                           }
                           assyQtyIn += result.getInt("Dieqty");
                       }
                       else
                       {
                           assyQtyIn = result.getInt("Dieqty");
                       }
                       if ( assyQtyIn > 0 )
                       {
                           assemblyLot.setQtyIn( assyQtyIn +"");
                           assemblyLot.setDateIn( StringUtils.formatDate(result.getString("Transaction Time"), "dd-MMM-yy HH:mm:ss", "MM/dd/yyyy HH:mm:ss" ) );
                           assemblyLot.setLotNumber( lotNumber );
                           assemblyLot.setDeviceName( partNumber );
                           assemblyLot.setFabLotNumber( fablotNumber );
                           assemblyLot.setDateCode( result.getString("Datecode"));
                       }
                   }
                   //ASSY SHIPPING
                   if ( result.getString("Process Stage") != null && "ASSEMBLY_OUT".equalsIgnoreCase(result.getString("Process Stage").trim() ) )
                   {
                          //log("In Assembly Shippping " + lotNumber );
                       shippedLot = ( ShippedLot ) m_assyShipDataMap.get ( partNumber + fablotNumber + lotNumber + result.getString("Transaction Time") );

                       if ( shippedLot == null )
                       {
                            shippedLot = new ShippedLot(vendor, LOCATION_TYPE_ASSEMBLY);
                            m_assyShipDataMap.put( partNumber + fablotNumber + lotNumber + result.getString("Transaction Time"), shippedLot );
                       }

                       int quantity = 0;
                       if ( shippedLot.getShipQty() != null )
                       {
                           try
                           {
                               quantity = Integer.parseInt( shippedLot.getShipQty() );
                           }
                           catch ( NumberFormatException ignore )
                           {
                               quantity = 0;
                           }

                           quantity += result.getInt("Dieqty");
                       }
                       else
                       {
                           quantity = result.getInt("Dieqty");
                       }

                       if ( quantity > 0 )
                       {
                           shippedLot.setLotNumber( lotNumber );
                           shippedLot.setPartNumber( partNumber );
                           shippedLot.setShipDate( StringUtils.formatDate(result.getString("Transaction Time"), "dd-MMM-yy HH:mm:ss", "MM/dd/yyyy HH:mm:ss" ) );
                           shippedLot.setShipQty( quantity + "" );
                           shippedLot.setFabLotNumber( fablotNumber );
                           shippedLot.setProcessType( LOCATION_TYPE_ASSEMBLY );

                       }
                   }
                }
            }
        }
        catch(Exception e)
        {
            e.printStackTrace();
            log("Exception while geting SCC,SCK,SCM Shipping inforamtion" + e);
            throw  e;

        }
    }

    private void getAllTransactionDetails(ArrayList<STATSWipStatus> shippingDataList) throws Exception
    {
       if ( shippingDataList == null || shippingDataList.size() == 0 )
       {
            return;
       }
       STATSWipStatus shipStatus  = null;
       String partNumber           = null;
       String lotNumber            = null;
       ShippedLot shippedLot       = null;
       AssemblyLot assemblyLot     = null;
       String fabLotNumber         = null;

       try
       {
           Iterator<STATSWipStatus> iterator = shippingDataList.iterator();

           while ( iterator.hasNext() )
           {
               shipStatus = (STATSWipStatus) iterator.next();

               lotNumber    = shipStatus.getSmLotId();
               partNumber   = shipStatus.getDeviceName();
               fabLotNumber = shipStatus.getFabLotNo();

               //FT SHIP
               if ( shipStatus.getProdArea() != null && "TEST_OUT".equalsIgnoreCase(shipStatus.getProdArea()) )
               {
                   //log("In FT Shippping " + lotNumber );
                   shippedLot = ( ShippedLot ) m_ftShipDataMap.get ( partNumber + lotNumber + fabLotNumber + shipStatus.getLotStartDate() );

                   if ( shippedLot == null )
                   {
                        shippedLot = new ShippedLot(VENDOR_NAME_SCS, LOCATION_TYPE_TEST );
                        m_ftShipDataMap.put( partNumber + lotNumber + fabLotNumber + shipStatus.getLotStartDate(), shippedLot );
                   }

                   int quantity = 0;
                   if ( shippedLot.getShipQty() != null )
                   {
                       try
                       {
                           quantity = Integer.parseInt( shippedLot.getShipQty() );
                       }
                       catch ( NumberFormatException ignore )
                       {
                           quantity = 0;
                       }
                       try
                       {
                           quantity += Integer.parseInt( shipStatus.getCurrDieQty() );
                       }
                       catch ( NumberFormatException ignore )
                       {
                           quantity = 0;
                       }
                   }
                   else
                   {
                       try
                       {
                           quantity = Integer.parseInt( shipStatus.getCurrDieQty() );
                       }
                       catch ( NumberFormatException ignore )
                       {
                           quantity = 0;
                       }
                   }

                   if ( quantity > 0 )
                   {
                       shippedLot.setLotNumber( lotNumber );
                       shippedLot.setPartNumber( partNumber );
                       shippedLot.setShipDate( shipStatus.getLotStartDate() );
                       shippedLot.setShipQty( quantity + "" );
                       shippedLot.setFabLotNumber( fabLotNumber );
                       shippedLot.setProcessType( LOCATION_TYPE_FT );
                   }
               }

               if ( shipStatus.getProdArea() != null && "ASSEMBLY_IN".equalsIgnoreCase(shipStatus.getProdArea()))
               {
                   assemblyLot = (AssemblyLot) m_assyYieldMap.get( partNumber + fabLotNumber + lotNumber );

                   if (assemblyLot == null)
                   {
                       assemblyLot = new AssemblyLot( VENDOR_NAME_SCS, LOCATION_TYPE_ASSEMBLY);
                       m_assyYieldMap.put( partNumber + fabLotNumber + lotNumber , assemblyLot );
                   }

                   int assyQtyIn = 0;
                   if ( assemblyLot.getQtyIn() != null)
                   {
                       try
                       {
                           assyQtyIn = Integer.parseInt( assemblyLot.getQtyIn() );
                       }
                       catch ( NumberFormatException ignore )
                       {
                           assyQtyIn = 0;
                       }
                       try
                       {
                           assyQtyIn += Integer.parseInt(shipStatus.getCurrDieQty());
                       }
                       catch ( NumberFormatException ignore )
                       {
                           assyQtyIn = 0;
                       }
                   }
                   else
                   {
                       try
                       {
                           assyQtyIn = Integer.parseInt(shipStatus.getCurrDieQty());
                       }
                       catch ( NumberFormatException ignore )
                       {
                           assyQtyIn = 0;
                       }
                   }
                   if ( assyQtyIn > 0 )
                   {
                       assemblyLot.setQtyIn( assyQtyIn +"");
                       assemblyLot.setDateIn( shipStatus.getLotStartDate() );
                       assemblyLot.setLotNumber( lotNumber );
                       assemblyLot.setDeviceName( partNumber );
                       assemblyLot.setFabLotNumber( fabLotNumber );
                       assemblyLot.setDateCode( shipStatus.getDateCode() );
                   }
               }
               //ASSY SHIPPING
               if ( shipStatus.getProdArea() != null && "ASSEMBLY_OUT".equalsIgnoreCase(shipStatus.getProdArea()) )
               {
                      //log("In Assembly Shippping " + lotNumber );
                   shippedLot = ( ShippedLot ) m_assyShipDataMap.get ( partNumber + fabLotNumber + lotNumber + shipStatus.getLotStartDate() );

                   if ( shippedLot == null )
                   {
                        shippedLot = new ShippedLot(VENDOR_NAME_SCS, LOCATION_TYPE_ASSEMBLY);
                        m_assyShipDataMap.put( partNumber + fabLotNumber + lotNumber + shipStatus.getLotStartDate(), shippedLot );
                   }

                   int quantity = 0;
                   if ( shippedLot.getShipQty() != null )
                   {
                       try
                       {
                           quantity = Integer.parseInt( shippedLot.getShipQty() );
                       }
                       catch ( NumberFormatException ignore )
                       {
                           quantity = 0;
                       }
                       try
                       {
                           quantity += Integer.parseInt( shipStatus.getCurrDieQty() );
                       }
                       catch ( NumberFormatException ignore )
                       {
                           quantity = 0;
                       }
                   }
                   else
                   {
                       try
                       {
                           quantity = Integer.parseInt( shipStatus.getCurrDieQty() );
                       }
                       catch ( NumberFormatException ignore )
                       {
                           quantity = 0;
                       }
                   }

                   if ( quantity > 0 )
                   {
                       shippedLot.setLotNumber( lotNumber );
                       shippedLot.setPartNumber( partNumber );
                       shippedLot.setShipDate( shipStatus.getLotStartDate() );
                       shippedLot.setShipQty( quantity + "" );
                       shippedLot.setFabLotNumber( fabLotNumber );
                       shippedLot.setProcessType( LOCATION_TYPE_ASSEMBLY );

                   }
               }
           }
        }
        catch(Exception e )
        {
            e.printStackTrace();
            log("Exception while geting STATS Shipping inforamtion" + e);
            throw  e;
        }
    }

    private void log( String message )
    {
        if ( message == null ) return;

        if ( m_parserLogger != null )
        {
            m_parserLogger.logDebug( message + LINE_SEPARATOR );
        }
        else
        {
            System.out.println( message );
        }
    } // end of log method
}
